/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package GameModel.Helper.impl;

import GameModel.Board;
import GameModel.Field;
import GameModel.GameModelFactory;

import GameModel.Helper.GameModelUtils;
import GameModel.Helper.HelperPackage;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Game Model Utils</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * </p>
 *
 * @generated
 */
public class GameModelUtilsImpl extends EObjectImpl implements GameModelUtils {
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GameModelUtilsImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return HelperPackage.Literals.GAME_MODEL_UTILS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	public void addAllFields(Board board) {
		for (int i = 0; i < board.getHeight(); i++) {
			for (int j = 0; j < board.getWidth(); j++) {
				Field newField = GameModelFactory.eINSTANCE.createField();
				newField.setX(j);
				newField.setY(i);

				board.getFields().add(newField);
			}
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eInvoke(int operationID, EList<?> arguments)
			throws InvocationTargetException {
		switch (operationID) {
		case HelperPackage.GAME_MODEL_UTILS___ADD_ALL_FIELDS__BOARD:
			addAllFields((Board) arguments.get(0));
			return null;
		}
		return super.eInvoke(operationID, arguments);
	}

} //GameModelUtilsImpl
